package com.platform.api.bzproject.service;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.platform.api.bzproject.dao.BzNoticeMapper;
import com.platform.api.bzproject.model.BzNotice;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * @author guoyunfei on 2021/7/9 14:04
 * @className BzNoticeMapper
 * @description TODO
 * @Version 1.0
 */
@Service
@Transactional(rollbackFor=Exception.class)
public class BzNoticeService extends ServiceImpl<BzNoticeMapper, BzNotice> {


    @Autowired
    private BzNoticeMapper bzNoticeDao;

    public List<BzNotice> selectList(BzNotice notice){
        List<BzNotice> list = bzNoticeDao.selectList(new QueryWrapper<BzNotice>()
                .eq("enable", notice.getEnable())
                .eq("type",notice.getType())
                .orderByDesc("is_top")
                .orderByDesc("create_time"));
        return list;
    }

    /**
     * 查询三天内的公告信息
     * @return
     */
    public int getDateSub3(){
        return bzNoticeDao.getDateSub3();
    }

}
